#include "sdlSprite.h"

int SDL_Sprite::load () {	 //#D
   //The image that's loaded 
   SDL_Surface* loadedImage = NULL; 
   //The optimized image that will be used is SDL_Sprite::sprite
   //Load the image using SDL_image 
   loadedImage = IMG_Load( getFileName().c_str() ); 
   //If the image loaded
   if( loadedImage != NULL ) { //Create an optimized image 
      setSurface( (void*) SDL_DisplayFormat( loadedImage ) ); 
      //Free the old image 
      SDL_FreeSurface( loadedImage ); 
      return 0;
   } 
   return -1;
}


SDL_Sprite::~SDL_Sprite () {	    //#D
   SDL_FreeSurface ( (SDL_Surface*) getSurface() );
}
